package com.oro.validator;

import java.util.Locale;
import java.util.ResourceBundle;

import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;

public class SelectOneMenuValidator implements Validator {

	@Override
	public void validate(FacesContext context, UIComponent component,
			Object value) throws ValidatorException {

		if (((String) value).equals("NO_INPUT")) {

			String baseName = context.getApplication().getMessageBundle();
			Locale currentLocale = context.getViewRoot().getLocale();
			ResourceBundle rb = ResourceBundle.getBundle(baseName,
					currentLocale);

			FacesMessage message = new FacesMessage();
			message.setSummary(rb.getString("select_one"));

			throw new ValidatorException(message);
		}

	}

}
